package com.rjwh.dingdong.client.mvp.model.impl;

import com.aishua.lib.task.AsResult;
import com.rjwh.dingdong.client.constant.NetConstant;
import com.rjwh.dingdong.client.mvp.BaseModel;
import com.rjwh.dingdong.client.mvp.BasePresenter;
import com.rjwh.dingdong.client.mvp.model.IMobileFastLoginModel;
import com.rjwh.dingdong.client.network.HttpWebService;
import com.rjwh.dingdong.client.network.HttpWebServiceCallBack;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Kay
 * @ClassName MobileFastLoginModel
 * @Description
 * @date 2016-10-13
 * @history 2016-10-13 author: description:
 */

public class MobileFastLoginModel extends BaseModel implements IMobileFastLoginModel, HttpWebServiceCallBack {

    public MobileFastLoginModel(BasePresenter basePresenter) {
        super(basePresenter);
    }

    /**
     * 手机号快捷登录
     *
     * @param account 手机号
     * @param smscode 验证码
     */
    @Override
    public void doSysSmsCodelogin(String account, String smscode) {
        Map<String, String> params = new HashMap<>();
        params.put("account", account);
        params.put("smscode", smscode);
        HttpWebService.getDataFromServer(NetConstant.SYSSMSCODELOGIN, params, true, this);
    }

    /**
     * 获取验证码
     *
     * @param inputPhone 手机号
     */
    @Override
    public void doGetCode(String inputPhone) {
        Map<String, String> params = new HashMap<>();
        params.put("phone", inputPhone);
        params.put("type", "1");
        HttpWebService.getDataFromServer(NetConstant.TYPE_SMS_CODE, params, true, this);
    }

    @Override
    public void onServerDataAcquired(int businessType, AsResult mAsResult, boolean isRefresh) {
        if (getBasePresenter() != null) {
            getBasePresenter().onServerDataAcquired(businessType, mAsResult, isRefresh);
        }
    }
}
